#include<stdio.h>
#include<stdarg.h>

int position(int arrinfo[],...)
{
	va_list va_name;
	int dimension=arrinfo[0],i=0,result=0;
	va_start(va_name,arrinfo);
	for(i=0;i<dimension;i++)
	{
		int num=va_arg(va_name,int);
		result=result*(arrinfo[2*i+2]-arrinfo[2*i+1]+1)+num-arrinfo[2*i+1];
	}
	va_end(va_name);
	return result;
}

int main()
{
	int arrinfo[]={2,1,6,2,9};
	printf("%d",position(arrinfo,4,6));
	return 0;
}
